package org.jeecg.enums.car;

import org.jeecg.common.util.StringUtils;

/**
 * 优惠券规则
 */
public enum CarDerateModeEnum {
    CAR_DERATE_TYPE_0("0", "全额减免"),
    CAR_DERATE_TYPE_1("1", "减免金额"),
    ;

    private String code;
    private String desc;

    CarDerateModeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }


    public static String getDesc(String value) {
        if (StringUtils.isBlank(value)) return "";
        CarDerateModeEnum[] enums = values();
        for (CarDerateModeEnum typeEnum : enums) {
            if (value.equals(typeEnum.getCode())) {
                return typeEnum.desc;
            }
        }
        return "";
    }

    public static String getValue(String desc) {
        CarDerateModeEnum[] enums = values();
        for (CarDerateModeEnum typeEnum : enums) {
            if (typeEnum.getDesc().equals(desc)) {
                return typeEnum.code;
            }
        }
        return null;
    }

}
